package com.wc.AlgoOJ_train.train1.c4.A411;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/1/10 14:23
 * @description 无限的路
 * http://43.138.190.70:8888/p/A411
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        double sqrt2 = Math.sqrt(2);
        double[][] dis = new double[200][200];
        double[] dp = new double[200];
        double pre = 0;
        for (int i = 1; i < 200; i++) {
            int y = i;
            int x = 0;
            int a = i;
            int b = i - 1;
            dp[i] = Math.sqrt(a * a + b * b);
            pre += dp[i];
            dis[x][y] = pre;
            while (y > 0) {
                x++;
                y--;
                pre += sqrt2;
                dis[x][y] = pre;
            }
        }
        int n = sc.nextInt();
        while (n-- > 0) {
            int x1 = sc.nextInt();
            int y1 = sc.nextInt();
            int x2 = sc.nextInt();
            int y2 = sc.nextInt();
            out.printf("%.3f\n", Math.abs(dis[x1][y1] - dis[x2][y2]));
        }
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }
}
